import Vue from 'vue';
import iView from 'iview';
import {router} from './router/index';
import {appRouter} from './router/router';
import store from './store';
import App from './app.vue';
import '@/locale';
import 'iview/dist/styles/iview.css';
import VueI18n from 'vue-i18n';
import util from './libs/util';
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import axios from 'axios';
import echarts from 'echarts';
import $ from 'jquery';
import  "@/views/api/axios";
import './views/api/css/css.css';
import hasPermission from '@/libs/hasPermission.js';

Vue.use(VueI18n);
Vue.use(iView);
Vue.use(ElementUI);
Vue.use(echarts);
Vue.use($);
Vue.use(hasPermission);
Vue.prototype.$echarts = echarts;
Vue.prototype.$http = axios;
Vue.prototype.$jq = $;


const vm = new Vue({
    el: "#app",
    router: router,
    store: store,
    render: h => h(App),
    data: {
        currentPageName: ""
    },
    mounted () {
        // console.log(hasPermission)
        //动态加载路由
        util.initRouter(this);

        this.currentPageName = this.$route.name;
        // 显示打开的页面的列表
        this.$store.commit("setOpenedList");
        this.$store.commit("initCachepage");

        // 静态路由
        // this.$store.commit('updateMenulist');
        // let tagsList = [];
        // appRouter.map((item) => {
        //     if (item.children.length <= 1) {
        //         tagsList.push(item.children[0]);
        //     } else {
        //         tagsList.push(...item.children);
        //     }
        // });
        // this.$store.commit('setTagsList', tagsList);
    }
});

export default vm;
